package dhm.com.dhmshop.updata.activity;

import android.os.Bundle;
import android.widget.TextView;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import dhm.com.dhmshop.R;
import dhm.com.dhmshop.base.BaseActiity;
import dhm.com.dhmshop.base.Presenter.PressenterImpl;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.base.netWork.LoginContract;
import dhm.com.dhmshop.entity.ComplaintDetailBean;
import dhm.com.dhmshop.utils.SpUtils;

public class ComplaintdetailActivity extends BaseActiity implements LoginContract.IView {

    @BindView(R.id.complaint_text)
    TextView complaintText;
    @BindView(R.id.content)
    TextView content;
    @BindView(R.id.type)
    TextView type;
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.message)
    TextView message;
    private PressenterImpl pressenter;

    @Override
    protected int getLayout() {
        return R.layout.activity_complaintdetail;
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        pressenter = new PressenterImpl();
        pressenter.attachView(this);

        String id = getIntent().getStringExtra("id");
        String shop_id = getIntent().getStringExtra("shop_id");

        String uid = SpUtils.getString(this, "uid");
        Map<String, String> map = new HashMap<>();
        map.put("token", Constant.TOKEN);
        map.put("uid", uid);
        map.put("shop_id", shop_id);
        map.put("id", id);
        pressenter.sendMessage(this, Constant.ComplainDetai, map, ComplaintDetailBean.class);

    }

    @Override
    protected void initData() {

    }

    @Override
    public void requesta(Object data) {
        if (data instanceof ComplaintDetailBean) {
            ComplaintDetailBean complaintDetailBean = (ComplaintDetailBean) data;
            complaintText.setText("订单：" + complaintDetailBean.getData().getOrderNo());
            content.setText(complaintDetailBean.getData().getComplainContent());
            type.setText("类型：" + complaintDetailBean.getData().getComplainType());
            time.setText(complaintDetailBean.getData().getComplainTime());
            switch (complaintDetailBean.getData().getComplainStatus()) {
                case 0:
                    message.setText("仲裁信息【等待处理】");
                    break;
                case 1:
                    message.setText("仲裁信息【等待被投诉方回应】");
                    break;
                case 2:
                case 3:
                    message.setText("仲裁信息【等待仲裁】");
                    break;
                case 4:
                    message.setText("仲裁信息【已仲裁】");
                    break;
                default:
            }
            switch (complaintDetailBean.getData().getComplainType()) {
                case 1:
                    type.setText("类型：承诺的没有做到");
                    break;
                case 2:
                    type.setText("类型：未按约定时间发货");
                    break;
                case 3:
                    type.setText("类型：未按成交价格进行交易");
                    break;
                case 4:
                    type.setText("类型：恶意骚扰");
                    break;
                default:
            }
        }
    }

    @Override
    public void fail(String error) {

    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }
}
